using CoreApi;
using CoreApi.Impl;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.InterceptionExtension;
using System.Web.Http;
using Unity.WebApi;
using Common.InterceptionBehavior;

namespace CoreService
{
    public static class UnityConfig
    {
        public static void RegisterComponents()
        {
			var container = new UnityContainer();
            
            // register all your components with the container here
            // it is NOT necessary to register your controllers
            
            // e.g. container.RegisterType<ITestService, TestService>();
            
            GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
            container.AddNewExtension<Interception>();
            container.RegisterType<IThresholder, Thresholder>(new ContainerControlledLifetimeManager()
                , new DefaultInterceptor(new InterfaceInterceptor())
                , new DefaultInterceptionBehavior(new LoggingInterceptionBehavior())
                );
            container.RegisterType<IDataCollect, SimpleDataCollect>(new ContainerControlledLifetimeManager()
                , new DefaultInterceptor(new InterfaceInterceptor())
                , new DefaultInterceptionBehavior(new LoggingInterceptionBehavior())
                );
            container.RegisterType<IPropertyManagerService,PropertyManagerService>(new ContainerControlledLifetimeManager()
                , new DefaultInterceptor(new InterfaceInterceptor())
                ,new DefaultInterceptionBehavior(new LoggingInterceptionBehavior())
                );
            container.RegisterType<IUserService, UserService>(new ContainerControlledLifetimeManager()
                , new DefaultInterceptor(new InterfaceInterceptor())
                , new DefaultInterceptionBehavior(new LoggingInterceptionBehavior())
                );
        }
    }
}